package com.gitee.dupe.authority.entity;

import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.dolt.core.base.entity.Entity;
import com.gitee.dupe.authority.enumeration.ResourceTypeEnum;
import com.gitee.dupe.authority.enumeration.RoleResourceScopeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;

/**
 * <p>
 *
 * </p>
 *
 * @author LYH
 * @since 2020-06-30
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "Resource", description = "资源")
@TableName("b_resource")
public class Resource extends Entity<Long> {

    /**
     * 标识（支持多个，用,隔开）
     */
    @ApiModelProperty(value = "标识（支持多个，用;隔开）")
    @Length(max = 255)
    @TableField(value = "ident", condition = SqlCondition.LIKE)
    private String ident;

    /**
     * 名称
     */
    @ApiModelProperty(value = "名称", required = true)
    @NotBlank
    @Length(max = 255)
    @TableField(value = "name", condition = SqlCondition.LIKE)
    private String name;

    /**
     * 父级
     */
    @ApiModelProperty(value = "父级")
    @TableField(value = "parent_id")
    private Long parentId;

    /**
     * 类型
     */
    @ApiModelProperty(value = "类型")
    @TableField(value = "type")
    private ResourceTypeEnum type;

    /**
     * 访问路径
     */
    @ApiModelProperty(value = "访问路径")
    @TableField(value = "url")
    private String url;

    /**
     * 图标
     */
    @ApiModelProperty(value = "图标")
    @TableField(value = "icon")
    private String icon;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sort")
    private Integer sort;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Length(max = 255)
    @TableField(value = "remark")
    private String remark;

    /**
     * 作用域
     */
    @ApiModelProperty(value = "作用域")
    @TableField(value = "scope")
    private RoleResourceScopeEnum scope;

    @ApiModelProperty(value = "是否外部链接")
    @TableField(value = "external_link")
    private Boolean externalLink;

    @TableField(exist = false)
    @ApiModelProperty(hidden = true)
    private Resource parent;


}
